package cn.sundat.utils;

import java.util.UUID;



public class UploadUtils {
	
	/**
	 * 获取随机的文件名
	 * @param fileName
	 * @return
	 */
	public static String getUUIDName(String fileName) {
		//取根
		int index = fileName.lastIndexOf(".");
		String substring = "";
		if(index!=-1) {
			substring = fileName.substring(index, fileName.length());
		}
		//截取
		String uuid = UUID.randomUUID().toString().replaceAll("-", "");
		//uuid+fileName保证了文件的唯一性，下载时候还可保证原文件名称.
		return uuid+"-"+fileName;
	}
	
	/**
	 * 根据公司的名字获取公司的文件夹的名字
	 * @param companyName
	 * @return
	 */
	public static String getCompanyFileName(String companyName) {
		String companyFileName = String.valueOf(companyName.hashCode()).trim();
		return companyFileName;
	}
	
}
